package edu.nf.waimai.service.shop.impl;

import edu.nf.util.SerializeUtils;
import edu.nf.waimai.dao.shop.ShopDAO;
import edu.nf.waimai.dao.shop.impl.ShopDAOImpl;
import edu.nf.waimai.model.shop.Shop;
import edu.nf.waimai.model.shop.waimai.WaimaiShop;
import edu.nf.waimai.service.exception.CodeException;
import edu.nf.waimai.service.shop.ShopService;
import edu.nf.util.sms.SMSUtil;

import java.util.List;

/**
 * @Date 2023-06-20
 * @Author qiu
 * 商家业务实现类
 */
public class ShopServiceImpl implements ShopService {
    private ShopDAO shopDAO = new ShopDAOImpl();

    /**
     * 添加商家
     * @param shop1
     * @return
     */
    @Override
    public int registerShop(Shop shop1) {
        int row = 0;

        Shop shop = new ShopDAOImpl().equeryPhone(shop1.getShopPhone());
        if (shop != null) {
            throw new RuntimeException("该手机已注册！");
        }

        row = new ShopDAOImpl().registerShop(shop1);
        return row;
    }

    /**
     * 通过店铺名称查询全部
     * @param shopName
     * @return
     */
    @Override
    public List<Shop> listShopByShopName(String shopName) {
        return shopDAO.listShopByShopName(shopName);
    }

    /**
     * 查询全部商家
     * @return
     */
    @Override
    public List<Shop> listShop() {
        return shopDAO.listShop();
    }

    /**
     * 商家分页查询
     * @param shop
     * @param page
     * @param limit
     * @return
     */
    @Override
    public List<Shop> listShopPaging(Shop shop, int page, int limit) {
        return shopDAO.listShopPaging(shop, page, limit);
    }

    /**
     * 通过id删除商家
     * @param shopId
     * @return
     */
    @Override
    public int delShop(int shopId) {
        return shopDAO.delShop(shopId);
    }

}
